package com.xuecheng.content.api;

import com.xuecheng.content.model.dto.CourseTeacherDto;
import com.xuecheng.content.model.dto.EditCourseTeacherDto;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "师资管理接口")
@RestController
@RequiredArgsConstructor
public class CourseTeacherController {

    private final CourseTeacherService courseTeacherService;

    /**
     * 根据课程id查询教师信息
     *
     * @param courseId 课程id
     * @return
     */
    @ApiOperation("查询教师信息")
    @GetMapping("/courseTeacher/list/{courseId}")
    public List<CourseTeacherDto> listCourseTeacher(@PathVariable Long courseId) {
        return courseTeacherService.listCourseTeacher(courseId);
    }

    /**
     * 新增或者修改教师信息
     *
     * @param editCourseTeacherDto 新增教师信息
     * @return 返回课程教师信息
     */
    @ApiOperation("新增教师信息")
    @PostMapping("/courseTeacher")
    public CourseTeacherDto insertOrUpdate(@RequestBody EditCourseTeacherDto editCourseTeacherDto) {
        // 机构id，由于认证系统没有上线暂时硬编码
        Long companyId = 1232141425L;
        return courseTeacherService.insertOrUpdate(editCourseTeacherDto, companyId);
    }

    /**
     * 删除教师信息
     *
     * @param courseId        课程id
     * @param courseTeacherId 教师id
     */
    @ApiOperation("删除教师信息")
    @DeleteMapping("/courseTeacher/course/{courseId}/{courseTeacherId}")
    public void deleteCourseTeacher(@PathVariable("courseId") Long courseId, @PathVariable("courseTeacherId") Long courseTeacherId) {
        // 机构id，由于认证系统没有上线暂时硬编码
        Long companyId = 1232141425L;
        courseTeacherService.deleteCourseTeacher(courseId, courseTeacherId, companyId);
    }
}
